<template>
  <div>
    <!-- 搜索栏 -->

    <div class="header">
      <div class="ss">
        <span class="icon"></span>
        <span>商品搜索,共239款好物</span>
      </div>
    </div>

    <div class="content">
      <!-- 左侧导航栏 -->
      <div class="left">
        <ul class="left-ul">
          <li
            v-for="(item, index) in navData"
            :key="item.index"
            :class="{ an: indexs === index }"
            @click="an(index,item.id)"
          >
            {{ item.name }}
          </li>
        </ul>
      </div>
      <!-- 右侧展品 -->

      <div class="right">
        <div class="banner"><img :src="banner.banner_url" alt="" /></div>
        <div class="title">
          <span class="xian">—</span> {{ title }}分类
          <span class="xian">—</span>
        </div>

<div class="logo-1">
        <van-grid :border="false" :column-num="3">
                    <router-link :to="`/category/${item.id}`" tag="van-grid-item" v-for="item in demo" :key="item.id">
                          <van-image :src="item.wap_banner_url" alt="" />
                          <p>{{item.name}}</p>
                    
                </router-link>
        </van-grid>
</div>
       



      </div>


    </div>


  </div>
</template>

    <script>
import { indexaction, currentaction } from "@/api/category/index.js";
export default {
  data() {
    return {
      navData: [],
      indexs: 0,
      info: {},
      banner: "",
      title: "",
      demo: "",

    };
  },
  computed: {},
  async created() {
    var result = await indexaction();
    this.navData = result.categoryList;
    var info = await currentaction({
      id: this.navData[0].id,
    });
    this.info = info;
    this.banner = info.data.currentOne;
    this.title = info.data.currentOne.name;
    this.demo = info.data.currentOne.subList;
    console.log(info);
    console.log(result);
  },
  mounted() {},
  methods: {
   async an(index,id) {
      this.indexs = index;
     var info = await currentaction({
      id:id,
    });
    this.info = info;
    this.banner = info.data.currentOne;
    this.title = info.data.currentOne.name;
    this.demo = info.data.currentOne.subList;
      console.log(id);
    },
  },
};
</script>

    <style scoped lang="scss">
.header {
  height: 45px;
  padding: 0 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: solid 1px #f0f0f0;
  .ss {
    width: 345px;
    height: 28px;
    background-color: #ededed;

    border-radius: 4px;
    line-height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    .icon {
      background: url(http://yanxuan.nosdn.127.net/hxm/yanxuan-wap/p/20161201/style/img/icon-normal/search2-2fb94833aa.png)
        50% no-repeat;
      width: 14px;
      height: 14px;
      margin-right: 5px;
      background-size: 100%;
      display: inline-block;
    }
  }
}

.content {
  display: flex;

}

.left-ul {
  width: 81px;
  height: 100%;
  border-right: 1px solid #fbfbfb;
  li {
    height: 45px;
    font-size: 14px;
    color: #333;
    // border-left: 3px solid #ab2b2b;
    text-align: center;
    line-height: 45px;
  }
  .an {
    font-size: 18px;
    color: #ab2b2b;
    border-left: 3px solid #ab2b2b;
    text-align: center;
    line-height: 45px;
  }
}

.right {
  padding: 0 15px;
  .banner {
    width: 100%;
    height: 111px;
    margin-top: 10px;
    img {
      width: 100%;
      height: 100%;
    }
  }

  .title {
    height: 16px;
    padding: 25px 0;
    .xian {
      color: #999;
      text-align: center;
      font-size: 12px;
    }
  }


.logo-1{
    display: flex;
    flex-wrap: wrap;
    margin-bottom: 50px;
    p{
        margin: 0;
        color: #000;
        font-size: 12px;
    }
}
  
}
</style>
